import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class ioStream {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
//		fileOutputStream();
//		fileInputStream();
		
		//
		
//		fileWriter();	
//		fileReader();
		
//		bufferWriter();
//		bufferReader();
		
//		printer();
//		scanner();
		
		demo();
				
	}

	/**
	 * doc/ghi du lieu voi FileInputStream/FileOutputStream
	 * */
	private static void fileInputStream(){
		
		try {
			
			FileInputStream input = new FileInputStream("stream1.txt");
			
			String text = "";
			byte[]arr = new byte[2];					
			int n = 0;
			while ( (n = input.read(arr) ) !=-1 ) {
				String s = new String(arr);
				
				text+=s;
			}
						
//			while ( (n=input.read()) !=-1 ) {
//				
//				text += (char)n;
//				
//			}
			 
			
			//
			input.close();
			
			System.out.println(text);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	private static void fileOutputStream(){
		
		try {
			
			String s = "Xin chào các bạn 123456";
			//b1
			FileOutputStream output = new FileOutputStream("stream1.txt");
			
			//b2
			byte[] arr = s.getBytes();
			output.write(arr);
			
//			for (int i = 0; i < s.length(); i++) {
//				output.write( s.charAt(i) );
//			}
			
			//b3
			output.close();
			
			System.out.println("ghi file thanh cong!!!");
			
		} catch (FileNotFoundException e) {		
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	/**
	 * doc/ghi du lieu voi 
	 * */
	private static void fileReader(){
		
		try {
			
			FileReader input = new FileReader("stream2.txt");
			
			String text = "";								
			int n = 0;
			
			char[]arr = new char[512];
			n = input.read(arr);			
			
			text = new String(arr);
			
			//
			input.close();
			
			System.out.println(text);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	private static void fileWriter(){
		
		try {
			
			String s = "doc ghi voi fileWriter/fileReader";
			//b1
			FileWriter output = new FileWriter("stream2.txt");
			
			//b2
			output.write(s);
			
			//b3
			output.close();
			
			System.out.println("ghi file thanh cong!!!");
			
		} catch (FileNotFoundException e) {		
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	/**
	 * doc/ghi du lieu voi buffer 
	 * */
	private static void bufferReader(){
		
		try {
			
			BufferedReader input = new BufferedReader( new FileReader("stream3.txt") );
			
			String text = "";								
			int n = 0;
			
			char[]arr = new char[512];
			n = input.read(arr);		
						
			text = new String(arr);
			
			//
			input.close();
			
			System.out.println(text);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	private static void bufferWriter(){
		
		try {
			
			String s = "doc ghi voi buffer";
			//b1
			BufferedWriter output = new BufferedWriter( new FileWriter("stream3.txt") );
			
			//b2
			output.write(s);
			
			//b3
			output.close();
			
			System.out.println("ghi file thanh cong!!!");
			
		} catch (FileNotFoundException e) {		
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	/**
	 * doc/ghi du lieu voi scanner/priter 
	 * */
	private static void scanner(){
		
		try {
			
			Scanner input = new Scanner( new FileReader("stream4.txt") );
			
			String text = "";								
			
			while (input.hasNextFloat()) {
				
				float a = input.nextFloat();
								
				text += " " + a;
				
			}
			
			//
			input.close();
			
			System.out.println(text);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	private static void printer(){
		
		try {
			
			float a[] = {10.2f, 52.3f, 12.7f};			
			
			//b1
			PrintWriter output = new PrintWriter( "stream4.txt" );
			
			//b2
			for (int i = 0; i < a.length; i++) {
				output.println(a[i]);								
			}
			
			//b3
			output.close();
			
			System.out.println("ghi file thanh cong!!!");
			
			String s ="sadf asdf asd ddf";
			String[]arr = s.split(" ");
			
			
		} catch (FileNotFoundException e) {		
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	/*
	 * doc mang 1 chieu tu file
	 * file co cau truc nhu sau
	 * 4
	 * 1 2 3 4
	 * */
	private static void demo(){
		
		try {
			BufferedReader reader = new BufferedReader( new FileReader("bt1.txt") );
			
			String line1 = reader.readLine();
			String line2 = reader.readLine();
			
			int n = Integer.parseInt(line1);
			int arr[] = new int[n];
			
			String s[] = line2.split(" ");
			
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(s[i]); 
			}
			
			reader.close();
			//
			
			System.out.println("so ptu cua mang " + n);
			for (int i = 0; i < n; i++) {
				System.out.print(" " + arr[i]);
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
	}
	
}
